package goodenglish.interfaces.studyword;

import goodenglish.application.StudyPlanService;
import goodenglish.application.impl.StudyPlanServiceImpl;
import goodenglish.domain.model.lexicon.Lexicon;
import goodenglish.domain.model.lexicon.StudyPlan;
import goodenglish.interfaces.BeanFactory;
import goodenglish.interfaces.Main;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;

public class CreateStudyPlanDlg extends BorderPane {
	private Lexicon lexicon;

	public CreateStudyPlanDlg(Lexicon lexicon) {
		this.lexicon = lexicon;
		this.getStyleClass().add("messageDialog");
		setMaxSize(500, 350);
		this.setTop(new Label("单词学习向导-新建计划"));
		VBox vBox = new VBox();
		this.setCenter(vBox);
		addBottom();

	}

	private void addBottom() {
		Button reviewBtn = new Button("完成");
		reviewBtn.setOnAction(new EventHandler<ActionEvent>() {

			public void handle(ActionEvent event) {
				StudyPlan studyPlan = lexiconService.addStudyPlan(lexicon);
				Main.instance.hideModalMessage();
				Main.root.setCenter(new StudyWordPane(studyPlan));

			}
		});
		this.setBottom(reviewBtn);
	}

	private StudyPlanService lexiconService = BeanFactory.getSingleInstance(StudyPlanServiceImpl.class);
}
